package game

import (
	"server/game/model"

	"github.com/hwcer/cosgo/times"
	"github.com/hwcer/cosmo"
	"github.com/hwcer/yyds/players"
)

func init() {
	players.Options.Preload = Preload(200)
}

type Preload int64

func (p Preload) TX() *cosmo.DB {
	tx := model.DB().Model(&model.Role{})
	tx = tx.Order("update", -1)

	ms := times.Now().Unix() - 7*86400
	tx = tx.Where("update >= ?", ms)

	return tx
}
func (p Preload) Limit() int64 {
	return int64(p)
}
